﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ControllerStudy2.Controllers
{
    public class OutputController : Controller
    {
        //
        // GET: /Output/
        public ActionResult WithLayout()
        {
            return View();
        }

        public ActionResult WithoutLayout()
        {
            return PartialView();
        }

        public ActionResult TextPlain()
        {
            return Content("Công cha như núi thái sơn");
        }

        public ActionResult FileContent()
        {
            return File("~/Upload/Ad320x50.png", "image/png");
        }

        public ActionResult ToOtherAction()
        {
            return RedirectToAction("About", "Home");
        }

        public ActionResult RedirectUrl()
        {
            return Redirect("http://www.google.com");
        }

        public ActionResult JSonObject()
        {
            var data = new { Name = "Phạm Thị Mỹ Ý", Salary = 600 };
            return Json(data, JsonRequestBehavior.AllowGet);
        }

        public ActionResult JSonArray()
        {
            var data = new []{ "Tuấn", "Hoa", "Hằng" };
            return Json(data, JsonRequestBehavior.AllowGet);
        }

        public ActionResult JSonArrayObject()
        {
            var data = new[] { 
                new{Name="Tuấn", Marks=7},
                new{Name="Hằng", Marks=9},
                new{Name="Hoa", Marks=4},
            };
            return Json(data, JsonRequestBehavior.AllowGet);
        }
	}
}